import React from "react";
import { Modal, Form, Input } from "antd";
import { modalPropsType } from '@/constants/types';

const {Item} = Form;
const rules = [{required: true, message: '此项必填'}];
const layout = {
  labelCol: {
    span: 5
  }
}


const TypeCreateModal = ({onSubmit, loading, onCancel, visible}: modalPropsType ) => {
  const [form] = Form.useForm();


  const handleSubmit = async () => {
    const res = await form.validateFields();
    onSubmit(res);
  }
  
  return (
    <Modal
      title="新增字典项"
      open={visible}
      width="520px"
      maskClosable={false}
      confirmLoading={loading}
      onOk={handleSubmit}
      onCancel={onCancel}
     >
      <Form form={form} {...layout}>
        <Item name="dictName" rules={rules} label="类型名称">
          <Input />
        </Item>
        <Item name="dictType" rules={rules} label="类型编码">
          <Input />
        </Item>
        <Item name="remark" label="备注">
          <Input />
        </Item>
      </Form>
     </Modal>
  );
}
export default TypeCreateModal;